import java.util.Scanner;

/**
 * <p>计算两个数的最大公约数</p>
 *
 * 辗转相除法
 *
 * @author: YuanChilde
 * @date: 2020-02-17 8:01
 * @version: 1.0
 * Modification History:
 * Date    Author      Version     Description
 * -----------------------------------------------------------------
 * 2020-02-17 8:01    YuanChilde     1.0        新增
 */
public class Demo4 {

    public static int getMaxYueShu(int a, int b) {
        if (b == 0) {
            return a;
        }
        return getMaxYueShu(b, a % b);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int number1 = sc.nextInt();
        int number2 = sc.nextInt();
        int maxInput = number1>number2?number1:number2;
        int minInput = number1>number2?number2:number1;
        int max = getMaxYueShu(maxInput,minInput);
        System.out.println(max);
    }
}
